#include <iostream>

using namespace std;

class FunctionObject;

//class function member point
typedef void (FunctionObject::*MemberFunc)();

class FunctionObject
{
public:
    //overload operator() to make object called like function
    void operator()();
    void operator->*(MemberFunc p);
    void print();
    MemberFunc p = &FunctionObject::operator();
};

void FunctionObject::operator()()
{
    this->print();
    cout << "void operator()()" << endl;
}

void FunctionObject::print()
{
    cout << "FunctionObject::print" << endl;
}

void FunctionObject::operator->*(MemberFunc p)
{
    //endless loop
    (this->*p)();
    cout << "FunctionObject::operator->*" << endl;
}

void test()
{
    FunctionObject *foo = new FunctionObject();
    /* foo->*(foo->p); */
}

int main()
{
    test();
    return 0;
}

